#! /usr/bin/env bash

echo $1
if [ "-h" = $1 -o "--help" = $1 ];then
	echo "-h,--help:show the help document for this shell script"
	echo "-f.--file:the pulseaudio file path,default:/opt/sys/settings/bin/sys/pulseaudio"
	exit
fi
fp=$1
echo "the file path:$fp"

cd /etc/default
if [ -f "pulseaudio" ];then
	if [ -h "pulseaudio" ];then
		echo "delete the symlink:pulseaudio"
		rm -f pulseaudio
	else
		echo "copy the pulseaudio file to pulseaudio.cp"
		mv pulseaudio pulseaudio.cp
	fi
fi
echo "link the symlink for pulseaudio"
ln -s $fp pulseaudio
echo "add the root to pulse-access group"
usermod -a -G pulse-access root	
echo "setting over,you must reboot"
